#include <stdio.h>
#include <string.h>
#include <sys/socket.h>

#include "page.h"

void to_index_path(int cfd)
{
    char buf[4096]="<html><head><title>服务器首页</title></head><body><h2>欢迎来到web服务器首页！</h2><p>Welcome！</p></body></html>";
    send(cfd, buf, strlen(buf), 0);
}

void to_notfound_page(int cfd)
{
    char buf[4096]="<html><head><title>页面找不到</title></head><body><h2>页面找不到</h2><p>sorry！</p></body></html>";
    send(cfd, buf, strlen(buf), 0);
}

void to_post_page(int cfd, char *username, char *passwd)
{
    char buf[4096];
    char fmt[] = "<html><head><title>Submit Successful</title></head><body style='background:green'><h2>Submit Successful!</h2><p>Hello, <b>%s</b>!</p><p>I won't tell anybody that your password is <em>%s</em>.</p></body></html>";
    sprintf(buf, fmt, username, passwd);
    printf("REPLY: %s\n", buf);
    send(cfd, buf, strlen(buf), 0);
}
